﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceable.App.Application.Command.Aquaculture;
using Traceable.App.DTOS;
using Traceable.ErrorCode;

namespace Traceable.App.Controllers
{
    /// <summary>
    /// 溯源养殖信息服务
    /// </summary>
    [Route("api/[controller][action]")]
    [ApiController]
    public class AquacultureController : ControllerBase
    {
        IMediator _mediator;
        /// <summary>
        /// 依赖注入
        /// </summary>
        /// <param name="mediator"></param>
        public AquacultureController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 获取养殖信息111
        /// </summary>
        /// <param name="request">请求参数</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<AquacultureDto>> GetAquaculture([FromQuery]GetAquacultureCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 修改养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> SaveAquacultrue(UpdateAquacultureCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 获取免疫信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<List<ImmunityDto>>> GetImmunity([FromQuery]GetImmunityCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 免疫新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> CreateImmunity(CreateImmunityCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 免疫信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpDelete]
        public Task<ApiResult<int>> DeleteImmunity([FromQuery]DeleteImmunityCommand request)
        {
            return _mediator.Send(request);
        }
    }
}
